package com.example.composableexample

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview

/**
 * author: LiLiang
 * createTime: 2022/10/4-22:06
 * remark:
 **/
@Preview
@Composable
fun CanvasSimple() {

    Canvas(modifier = Modifier.fillMaxSize(), onDraw = {
        val canvasWith = size.width
        val canvasHeight = size.height

//        drawLine(
//            start = Offset(x = canvasWith, y = 0f),
//            end = Offset(x = 0f, y = canvasHeight),
//            color = Color.Blue,
//            strokeWidth = 5f
//        )
//        drawCircle(
//            color = Color.Blue,
//            center = Offset(x = canvasWith / 2, y = canvasHeight / 2),
//            radius = size.minDimension / 4
//        )
        val canvasQuadrantSize = size / 2F
        drawRect(color = Color.Green, size = canvasQuadrantSize)
    })
}